﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Billing
{
    public class FormManager : ApplicationContext
    {
        public static int FormCount = 0;
        public static bool AllowQuit = true;
        public FormManager()
            : base()
        {
            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
            Application.EnterThreadModal += new EventHandler(Application_EnterThreadModal);
            Application.Idle += new EventHandler(Application_Idle);
            Application.LeaveThreadModal += new EventHandler(Application_LeaveThreadModal);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.ThreadExit += new EventHandler(Application_ThreadExit);

        }

        public static void frm_FormClosed(object sender, FormClosedEventArgs e)
        {
            FormCount--;

        }

        public static void frm_FormClosing(object sender, FormClosingEventArgs e)
        {

        }

        public static void frm_FormLoad(object sender, EventArgs e)
        {
            FormCount++;
        }


        void Application_ThreadExit(object sender, EventArgs e)
        {

        }

        void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {

        }

        #region Modal Form Events
        void Application_EnterThreadModal(object sender, EventArgs e)
        {

        }
        void Application_LeaveThreadModal(object sender, EventArgs e)
        {

        }
        #endregion

        void Application_Idle(object sender, EventArgs e)
        {
            FormCollection fc = Application.OpenForms;
        }


        void Application_ApplicationExit(object sender, EventArgs e)
        {

        }

        public FormManager(System.Windows.Forms.Form mainform)
            : base(mainform)
        {
            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
            Application.EnterThreadModal += new EventHandler(Application_EnterThreadModal);
            Application.Idle += new EventHandler(Application_Idle);
            Application.LeaveThreadModal += new EventHandler(Application_LeaveThreadModal);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.ThreadExit += new EventHandler(Application_ThreadExit);
        }
    }
}
